package edu.zjut.hjg.saas.web.controller.home;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import edu.zjut.hjg.saas.biz.service.UserLogService;

@Controller
@RequestMapping("/home/fresh.htm")
public class FreshController {

    @Value("${saas.web.app.server.port}")
    private int            appServerPort;

    @Autowired
    private UserLogService userLogService;

    @RequestMapping
    public void fresh(Model model) {
        model.addAttribute("userLogs", userLogService.listFreshByLimit(10));
        model.addAttribute("port", (appServerPort == 80 ? "" : ":" + appServerPort));
    }
}
